<?php

include '../config/db_config.php';
include '../lib/kelola_kategori.php';

session_start();

if(!isset($_SESSION['USERNAME'])){
	header('location:login.php');
}

$kelola_kategori = new kelola_kategori();

$all_kategori = $kelola_kategori->get_all_kategori();

?>

<html>
  <head>
    <title>Smart Commerce</title>
    <link href="../css/bootstrap.min.css" rel="stylesheet">
	<style type="text/css">
      body {
        padding-top: 60px;
        padding-bottom: 40px;
      }
    </style>
    <link href="../css/bootstrap-responsive.min.css" rel="stylesheet">
	<script src="../js/jquery-1.7.2.min.js"></script>
	<script src="../js/bootstrap.min.js"></script>
	<script src="../js/autoNumeric-1.7.5.js"></script>
</head>
<body>
	<div class="navbar navbar-inverse navbar-fixed-top">
		<div class="navbar-inner">
			<div class="container">
			<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
			</a>
			
			<a class="brand" href="home_technopreneur.php">Beranda</a>
			<a class="brand">Tentang Kami</a>
			<a class="brand">Kontak</a>
			
				<div class="nav-collapse collapse">
				<form class="navbar-form pull-right" method="post">
				</form>
			<form class="navbar-form pull-right" method="post">
				<a href="../logout.php" class="btn btn-small btn-primary pull-right">Logout</a>
				<a href="edit_profil.php" class="btn btn-small btn-primary pull-right">Edit Profil</a>
			</form>
				
			    </div>
			</div>
		</div>
    </div>
	
	<div class="container">
		<div class="hero-unit"style="background-image:url('../images/header.jpg');" >
			<h1>Smart Commerce</h1>
			<blockquote class="pull-right"> 
				<p>Website khusus Technopreneur Surabaya</p>
			</blockquote>
		</div>
		
		<ul class="breadcrumb">
			<li><a href="home_technopreneur.php">Home</a> <span class="divider">/</span></li>
			<li class="active">Tambah Produk</li>
		</ul>
		
		<form name="input" action="../tambah_produk.php" method="post" enctype="multipart/form-data">
		<div class="control-group">
			<label class="control-label" for="inputUser">Nama Produk</label>
			<div class="controls">
				<input style="width:400px; height:30px" type="text" name="nama_produk" placeholder="Nama Produk" autofocus="autofocus" autocomplete="off" maxlength="32" required="required">
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="inputUser">Kategori Produk</label>
			<div class="controls">
				<select name="id_kategori">
					<?php
					foreach($all_kategori as $kategori){
						echo '<option value="'.$kategori['ID_KATEGORI'].'">'.$kategori['NAMA_KATEGORI'].'</option>';
					}
					?>
				</select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="inputPassword">Harga</label>
			<div class="controls">
				<div class="input-prepend input-append">
				  <span class="add-on">Rp.</span>
				  <input id="harga" class="span2" name="harga" style="width:300px;height:30px;text-align:right;" min="1" required>
				</div>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="inputPassword">Deskripsi Produk</label>
			<div class="controls">
				<textarea name="deskripsi" rows="7" style="width:400px;" type="text" name="password" placeholder="" maxlength="1024" required="required"></textarea>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="inputPassword">Gambar</label>
			<div class="controls">
				<input class="input-large" type="file" name="gambar1" accept="image/png,image/jpeg,image/jpg"></br>
				<textarea name="deskripsi_gambar1" rows="1" style="width:400px;display:block;" type="text" name="password" placeholder="Deskripsi Gambar 1" maxlength="512"></textarea>
				<div id="upload2" style="display:none;">
					<input class="input-large" type="file" name="gambar2" accept="image/png,image/jpeg,image/jpg" style="display:block;">
					<textarea name="deskripsi_gambar2" rows="1" style="width:400px;display:block;" type="text" name="password" placeholder="Deskripsi Gambar 2" maxlength="512"></textarea>
				</div>
				<div id="upload3" style="display:none;">
					<input class="input-large" type="file" name="gambar3" accept="image/png,image/jpeg,image/jpg" style="display:block;">
					<textarea name="deskripsi_gambar3" rows="1" style="width:400px;display:block;" type="text" name="password" placeholder="Deskripsi Gambar 3" maxlength="512"></textarea>
				</div>
				<div id="upload4" style="display:none;">
					<input class="input-large" type="file" name="gambar4" accept="image/png,image/jpeg,image/jpg" style="display:block;">
					<textarea name="deskripsi_gambar4" rows="1" style="width:400px;display:block;" type="text" name="password" placeholder="Deskripsi Gambar 4" maxlength="512"></textarea>
				</div>
				<div id="upload5" style="display:none;">
					<input class="input-large" type="file" name="gambar5" accept="image/png,image/jpeg,image/jpg" style="display:block;">
					<textarea name="deskripsi_gambar5" rows="1" style="width:400px;display:block;" type="text" name="password" placeholder="Deskripsi Gambar 5" maxlength="512"></textarea>
				</div>
				<small><span class="help-block">Max 200 kb. jpg / jpeg / png</span></small>
			</div>
		</div>
		<a class="btn btn-mini" id="tambah"><i class="icon-plus"></i> tambah</a></br></br>
		<div class="control-group">
			<div class="controls">
				<button type="reset" class="btn">Reset</button>
				<button type="submit" class="btn">Tambah</button> 
			</div>
		</div>
		</form>
		
		
	</div>

	<script>
		$(document).ready(function()
		{
			$('#harga').keyup(function()
			{
				$('#harga').autoNumeric({
					aSep:'.',
					dGroup:'3',
					aDec:',',
					vMax:'999999999999',
					mDec:'0'
				});
				
			});
			
			var i = 1;
			$('#tambah').click(function () {
				i++;
				//$('input[name="gambar' + i + '"]').css('display', 'block');
				$('#upload' + i).css('display', 'block');
				if(i == 5){
					$('#tambah').css('display','none');
				}
			});
			
		});

		
	</script>
  </body>
</html>